//package com.qfoud.edu.shiro.framwork.filter;
//
//import com.qfoud.edu.shiro.framwork.auth.AuthticationInfo;
//import com.qfoud.edu.shiro.framwork.exception.ShiroException;
//import com.qfoud.edu.shiro.framwork.manager.AuthticationManager;
//import com.qfoud.edu.shiro.framwork.manager.impl.AuthticationManagerImpl;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.io.UnsupportedEncodingException;
//import java.lang.reflect.InvocationTargetException;
//
///**
// * @author xiaobobo
// * @title: AuthticationProxyFilter
// * @projectName cd-java-2303-project-parent
// * @description: 这个过滤器的作用就是完成用户的登陆认证
// * @date 2023/5/11  15:19
// */
//public class AuthticationProxyFilter implements Filter {
//
//    private AuthticationManager authticationManager=new AuthticationManagerImpl();
//
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        //首先要取出我们的数据
//        AuthticationInfo authticationInfo=getAuthticationInfo(servletRequest);
//        try {
//            authticationManager.auth(authticationInfo,servletRequest,servletResponse);
//        } catch (InvocationTargetException e) {
//            e.printStackTrace();
//        } catch (IllegalAccessException e) {
//            e.printStackTrace();
//        }
//    }
//
//    /**
//     * 取出用户信息
//     * 登陆只能使用post方式去登陆
//     * @param servletRequest
//     * @return
//     */
//    private AuthticationInfo getAuthticationInfo(ServletRequest servletRequest) throws UnsupportedEncodingException {
//        HttpServletRequest request= (HttpServletRequest) servletRequest;
//        request.setCharacterEncoding("UTF-8");
//        String method = request.getMethod();
//        AuthticationInfo authticationInfo=new AuthticationInfo();
//        if("POST".equalsIgnoreCase(method)){
//            //说明前端是POST方法满足我们的条件
//            //取出用户名和密码
//            String username = request.getParameter("username");
//            String password = request.getParameter("password");
//            //接下来将这两个信息封装到AuthticationInfo中去
//            authticationInfo.setUsername(username);
//            authticationInfo.setPassword(password);
//        }else{
//            throw new ShiroException("请求方法不是POST登陆不支持");
//        }
//        return authticationInfo;
//    }
//}
